package com.wz.project.util;

import com.wz.common.utils.uuid.UUID;
import com.wz.project.api.InterfaceLog.domain.InterfaceLog;
import com.wz.project.api.InterfaceLog.mapper.InterfaceLogMapper;
import com.wz.project.api.InterfaceLog.service.IInterfaceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @auInterfaceLogUtilthor jinhuijiang
 * @create 2021-11-17 16:34
 */
@Component
public class InterfaceLogUtil {
    @Autowired
    InterfaceLogMapper interfaceLogMapper;

    private static InterfaceLogUtil interfaceLogUtil;


    @PostConstruct
    public void init() {
        interfaceLogUtil = this;
        interfaceLogUtil.interfaceLogMapper = this.interfaceLogMapper;

    }

    public static void setLog(String system, String data, String result) {
        InterfaceLog interfaceLog = new InterfaceLog();
        interfaceLog.setId(UUID.randomUUID().toString());
        interfaceLog.setSystem(system);
        interfaceLog.setSend(data);
        interfaceLog.setResult(result);
        interfaceLog.setTimes(DateUtill.localDateTime(DateUtill.DATE_TIME_PATTERN));
        interfaceLogUtil.interfaceLogMapper.insertInterfaceLog(interfaceLog);
    }
}
